from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware

from api.xcx.shop import xcx

app = FastAPI(title="uniapp 商城接口",
    description="该项目是配套uniapp学习的接口，本质使用的是 https://www.bilibili.com/video/BV1BJ411W7pX?t=113&p=55 所需要的接口服务，使用了FastAPI 复制了一份")


app.include_router(xcx, prefix="/v1")


def create_app():
    # 设置跨域
    app.add_middleware(
        CORSMiddleware,
        allow_origins=["*",],
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
    )
    return app